package org.gnuhpc.util;

import org.gnuhpc.R;

import android.content.Context;
import android.content.SharedPreferences;
import android.content.SharedPreferences.OnSharedPreferenceChangeListener;
import android.os.Bundle;
import android.preference.Preference;
import android.preference.PreferenceActivity;
import android.preference.PreferenceManager;
import android.preference.Preference.OnPreferenceClickListener;
import android.util.Log;

public class Prefs extends PreferenceActivity implements OnSharedPreferenceChangeListener,OnPreferenceClickListener {
	private static final String LOG_TAG = "ShowLocation";
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		addPreferencesFromResource(R.menu.prefs);		
		Context context = getApplicationContext();
		SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
		prefs.registerOnSharedPreferenceChangeListener(this);		
	}

	public void onSharedPreferenceChanged(SharedPreferences sharedPreferences,
			String key) {
		Log.d(LOG_TAG,"key is:" + key);
	}
	
	public boolean onPreferenceClick(Preference preference) {
		// TODO Auto-generated method stub
		return false;
	}
	
	 public static boolean getCompass(Context context){
		 return PreferenceManager.getDefaultSharedPreferences(context).getBoolean("compass", true);
	 }
	 
	 public static String getGPSPref(Context context){
		 return PreferenceManager.getDefaultSharedPreferences(context).getString("gpsPref", "1");
	 }
	 
	 public static String getLocationPref(Context context){
		 return PreferenceManager.getDefaultSharedPreferences(context).getString("locPref", "1");
	 }

	 public static boolean getDisplayRoutePref(Context context){
		 return PreferenceManager.getDefaultSharedPreferences(context).getBoolean("routeDispPref", true);
	 }
	 
	 public static boolean getDisplayLocationInfoPref(Context context){
		 return PreferenceManager.getDefaultSharedPreferences(context).getBoolean("locInfoPref", false);
	 }
	 
	 public static String getTimeCalcPref(Context context){
		 return PreferenceManager.getDefaultSharedPreferences(context).getString("timeCalcPref", "1");
	 }
}
